package com.dailyblue.java.spring.cloud.example.gateway.filter;

import com.dailyblue.java.spring.cloud.example.gateway.config.MessageConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

import java.util.Arrays;
import java.util.List;

@Component
@Slf4j
public class MessageGatewayFilterFactory extends AbstractGatewayFilterFactory<MessageConfig> {

    public MessageGatewayFilterFactory() {
        super(MessageConfig.class);
    }

    @Override
    public GatewayFilter apply(MessageConfig config) {
        log.info("名字分别是：{}", config);
        GatewayFilter f = (exchange, chain) -> chain.filter(exchange);
        return f;
    }

    @Override
    public List<String> shortcutFieldOrder() {
        return Arrays.asList("firstArray", "secondArray");
    }
}
